.class public Lweibo4android/http/ImageItem;
.super Ljava/lang/Object;
.source "ImageItem.java"


# instance fields
.field private ImageType:Ljava/lang/String;

.field private content:[B

.field private name:Ljava/lang/String;


# direct methods
.method public constructor <init>(Ljava/lang/String;[B)V
    .locals 3
    .parameter "name"
    .parameter "content"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 31
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 32
    invoke-static {p2}, Lweibo4android/http/ImageItem;->getImageType([B)Ljava/lang/String;

    move-result-object v0

    .line 34
    .local v0, imgtype:Ljava/lang/String;
    if-eqz v0, :cond_1

    const-string v1, "image/gif"

    invoke-virtual {v0, v1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v1

    if-nez v1, :cond_0

    const-string v1, "image/png"

    invoke-virtual {v0, v1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v1

    if-nez v1, :cond_0

    .line 35
    const-string v1, "image/jpeg"

    invoke-virtual {v0, v1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 36
    :cond_0
    iput-object p2, p0, Lweibo4android/http/ImageItem;->content:[B

    .line 37
    iput-object p1, p0, Lweibo4android/http/ImageItem;->name:Ljava/lang/String;

    .line 38
    iput-object v0, p0, Lweibo4android/http/ImageItem;->ImageType:Ljava/lang/String;

    .line 43
    return-void

    .line 40
    :cond_1
    new-instance v1, Ljava/lang/IllegalStateException;

    .line 41
    const-string v2, "Unsupported image type, Only Suport JPG ,GIF,PNG!"

    .line 40
    invoke-direct {v1, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v1
.end method

.method public constructor <init>([B)V
    .locals 1
    .parameter "content"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 45
    const-string v0, "pic"

    invoke-direct {p0, v0, p1}, Lweibo4android/http/ImageItem;-><init>(Ljava/lang/String;[B)V

    .line 46
    return-void
.end method

.method public static getImageType(Ljava/io/File;)Ljava/lang/String;
    .locals 6
    .parameter "file"

    .prologue
    const/4 v3, 0x0

    .line 58
    if-eqz p0, :cond_0

    invoke-virtual {p0}, Ljava/io/File;->exists()Z

    move-result v4

    if-nez v4, :cond_1

    .line 67
    :cond_0
    :goto_0
    return-object v3

    .line 61
    :cond_1
    const/4 v1, 0x0

    .line 63
    .local v1, in:Ljava/io/InputStream;
    :try_start_0
    new-instance v2, Ljava/io/FileInputStream;

    invoke-direct {v2, p0}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1

    .line 64
    .end local v1           #in:Ljava/io/InputStream;
    .local v2, in:Ljava/io/InputStream;
    :try_start_1
    invoke-static {v2}, Lweibo4android/http/ImageItem;->getImageType(Ljava/io/InputStream;)Ljava/lang/String;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_4

    move-result-object v3

    .line 70
    .local v3, type:Ljava/lang/String;
    if-eqz v2, :cond_0

    .line 71
    :try_start_2
    invoke-virtual {v2}, Ljava/io/InputStream;->close()V
    :try_end_2
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0

    goto :goto_0

    .line 73
    :catch_0
    move-exception v4

    goto :goto_0

    .line 66
    .end local v2           #in:Ljava/io/InputStream;
    .end local v3           #type:Ljava/lang/String;
    .restart local v1       #in:Ljava/io/InputStream;
    :catch_1
    move-exception v0

    .line 70
    .local v0, e:Ljava/io/IOException;
    :goto_1
    if-eqz v1, :cond_0

    .line 71
    :try_start_3
    invoke-virtual {v1}, Ljava/io/InputStream;->close()V
    :try_end_3
    .catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_2

    goto :goto_0

    .line 73
    :catch_2
    move-exception v4

    goto :goto_0

    .line 68
    .end local v0           #e:Ljava/io/IOException;
    :catchall_0
    move-exception v4

    .line 70
    :goto_2
    if-eqz v1, :cond_2

    .line 71
    :try_start_4
    invoke-virtual {v1}, Ljava/io/InputStream;->close()V
    :try_end_4
    .catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_3

    .line 75
    :cond_2
    :goto_3
    throw v4

    .line 73
    :catch_3
    move-exception v5

    goto :goto_3

    .line 68
    .end local v1           #in:Ljava/io/InputStream;
    .restart local v2       #in:Ljava/io/InputStream;
    :catchall_1
    move-exception v4

    move-object v1, v2

    .end local v2           #in:Ljava/io/InputStream;
    .restart local v1       #in:Ljava/io/InputStream;
    goto :goto_2

    .line 66
    .end local v1           #in:Ljava/io/InputStream;
    .restart local v2       #in:Ljava/io/InputStream;
    :catch_4
    move-exception v0

    move-object v1, v2

    .end local v2           #in:Ljava/io/InputStream;
    .restart local v1       #in:Ljava/io/InputStream;
    goto :goto_1
.end method

.method public static getImageType(Ljava/io/InputStream;)Ljava/lang/String;
    .locals 4
    .parameter "in"

    .prologue
    const/4 v2, 0x0

    .line 85
    if-nez p0, :cond_0

    .line 93
    :goto_0
    return-object v2

    .line 89
    :cond_0
    const/16 v3, 0x8

    :try_start_0
    new-array v0, v3, [B

    .line 90
    .local v0, bytes:[B
    invoke-virtual {p0, v0}, Ljava/io/InputStream;->read([B)I

    .line 91
    invoke-static {v0}, Lweibo4android/http/ImageItem;->getImageType([B)Ljava/lang/String;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v2

    goto :goto_0

    .line 92
    .end local v0           #bytes:[B
    :catch_0
    move-exception v1

    .line 93
    .local v1, e:Ljava/io/IOException;
    goto :goto_0
.end method

.method public static getImageType([B)Ljava/lang/String;
    .locals 1
    .parameter "bytes"

    .prologue
    .line 103
    invoke-static {p0}, Lweibo4android/http/ImageItem;->isJPEG([B)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 104
    const-string v0, "image/jpeg"

    .line 115
    :goto_0
    return-object v0

    .line 106
    :cond_0
    invoke-static {p0}, Lweibo4android/http/ImageItem;->isGIF([B)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 107
    const-string v0, "image/gif"

    goto :goto_0

    .line 109
    :cond_1
    invoke-static {p0}, Lweibo4android/http/ImageItem;->isPNG([B)Z

    move-result v0

    if-eqz v0, :cond_2

    .line 110
    const-string v0, "image/png"

    goto :goto_0

    .line 112
    :cond_2
    invoke-static {p0}, Lweibo4android/http/ImageItem;->isBMP([B)Z

    move-result v0

    if-eqz v0, :cond_3

    .line 113
    const-string v0, "application/x-bmp"

    goto :goto_0

    .line 115
    :cond_3
    const/4 v0, 0x0

    goto :goto_0
.end method

.method private static isBMP([B)Z
    .locals 4
    .parameter "b"

    .prologue
    const/4 v1, 0x1

    const/4 v0, 0x0

    .line 143
    array-length v2, p0

    const/4 v3, 0x2

    if-ge v2, v3, :cond_1

    .line 146
    :cond_0
    :goto_0
    return v0

    :cond_1
    aget-byte v2, p0, v0

    const/16 v3, 0x42

    if-ne v2, v3, :cond_0

    aget-byte v2, p0, v1

    const/16 v3, 0x4d

    if-ne v2, v3, :cond_0

    move v0, v1

    goto :goto_0
.end method

.method private static isGIF([B)Z
    .locals 5
    .parameter "b"

    .prologue
    const/4 v4, 0x4

    const/4 v1, 0x1

    const/4 v0, 0x0

    .line 126
    array-length v2, p0

    const/4 v3, 0x6

    if-ge v2, v3, :cond_1

    .line 130
    :cond_0
    :goto_0
    return v0

    .line 129
    :cond_1
    aget-byte v2, p0, v0

    const/16 v3, 0x47

    if-ne v2, v3, :cond_0

    aget-byte v2, p0, v1

    const/16 v3, 0x49

    if-ne v2, v3, :cond_0

    const/4 v2, 0x2

    aget-byte v2, p0, v2

    const/16 v3, 0x46

    if-ne v2, v3, :cond_0

    const/4 v2, 0x3

    aget-byte v2, p0, v2

    const/16 v3, 0x38

    if-ne v2, v3, :cond_0

    .line 130
    aget-byte v2, p0, v4

    const/16 v3, 0x37

    if-eq v2, v3, :cond_2

    aget-byte v2, p0, v4

    const/16 v3, 0x39

    if-ne v2, v3, :cond_0

    :cond_2
    const/4 v2, 0x5

    aget-byte v2, p0, v2

    const/16 v3, 0x61

    if-ne v2, v3, :cond_0

    move v0, v1

    goto :goto_0
.end method

.method private static isJPEG([B)Z
    .locals 4
    .parameter "b"

    .prologue
    const/4 v1, 0x1

    const/4 v0, 0x0

    .line 119
    array-length v2, p0

    const/4 v3, 0x2

    if-ge v2, v3, :cond_1

    .line 122
    :cond_0
    :goto_0
    return v0

    :cond_1
    aget-byte v2, p0, v0

    const/4 v3, -0x1

    if-ne v2, v3, :cond_0

    aget-byte v2, p0, v1

    const/16 v3, -0x28

    if-ne v2, v3, :cond_0

    move v0, v1

    goto :goto_0
.end method

.method private static isPNG([B)Z
    .locals 5
    .parameter "b"

    .prologue
    const/16 v4, 0xa

    const/4 v1, 0x1

    const/4 v0, 0x0

    .line 134
    array-length v2, p0

    const/16 v3, 0x8

    if-ge v2, v3, :cond_1

    .line 139
    :cond_0
    :goto_0
    return v0

    .line 137
    :cond_1
    aget-byte v2, p0, v0

    const/16 v3, -0x77

    if-ne v2, v3, :cond_0

    aget-byte v2, p0, v1

    const/16 v3, 0x50

    if-ne v2, v3, :cond_0

    const/4 v2, 0x2

    aget-byte v2, p0, v2

    const/16 v3, 0x4e

    if-ne v2, v3, :cond_0

    .line 138
    const/4 v2, 0x3

    aget-byte v2, p0, v2

    const/16 v3, 0x47

    if-ne v2, v3, :cond_0

    const/4 v2, 0x4

    aget-byte v2, p0, v2

    const/16 v3, 0xd

    if-ne v2, v3, :cond_0

    const/4 v2, 0x5

    aget-byte v2, p0, v2

    if-ne v2, v4, :cond_0

    .line 139
    const/4 v2, 0x6

    aget-byte v2, p0, v2

    const/16 v3, 0x1a

    if-ne v2, v3, :cond_0

    const/4 v2, 0x7

    aget-byte v2, p0, v2

    if-ne v2, v4, :cond_0

    move v0, v1

    goto :goto_0
.end method


# virtual methods
.method public getContent()[B
    .locals 1

    .prologue
    .line 49
    iget-object v0, p0, Lweibo4android/http/ImageItem;->content:[B

    return-object v0
.end method

.method public getImageType()Ljava/lang/String;
    .locals 1

    .prologue
    .line 55
    iget-object v0, p0, Lweibo4android/http/ImageItem;->ImageType:Ljava/lang/String;

    return-object v0
.end method

.method public getName()Ljava/lang/String;
    .locals 1

    .prologue
    .line 52
    iget-object v0, p0, Lweibo4android/http/ImageItem;->name:Ljava/lang/String;

    return-object v0
.end method
